package com.frank.twloading.slice;

import com.frank.loadinglibrary.common.*;
import com.frank.loadinglibrary.common.gear.TwoGearsLoadingComponent;
import com.frank.loadinglibrary.common.other.ChromeFloatingCirclesComponent;
import com.frank.loadinglibrary.common.other.FoldingCirclesComponent;
import com.frank.loadinglibrary.common.ring.CircularRingComponent;
import com.frank.loadinglibrary.common.ring.RingGradientLoading;
import com.frank.loadinglibrary.common.ring.WhorArcLoadingComponent;
import com.frank.loadinglibrary.common.search.SearchLoadingComponent;
import com.frank.loadinglibrary.cool.SandClockComponent;
import com.frank.loadinglibrary.special.BallJumpLoadingComponent;
import com.frank.loadinglibrary.special.ElectricFanLoadingComponent;
import com.frank.loadinglibrary.special.SlackLoadingComponent;
import com.frank.loadinglibrary.special.eatbean.EatBeansComponent;
import com.frank.twloading.ComponentItemProvider;
import com.frank.twloading.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.colors.RgbPalette;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;
import ohos.agp.components.TableLayoutManager;
import ohos.agp.components.element.ShapeElement;

import java.util.ArrayList;

public class NormalAbilitySlice extends BaseSlice {

    private ArrayList<Component> items;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_normal);
        initData();
        ShapeElement element = new ShapeElement();
        element.setRgbColor(new RgbColor(231, 87, 100));


        ListContainer listContainer = getComponentById(ResourceTable.Id_listContainer);
        TableLayoutManager tableLayoutManager = new TableLayoutManager();
        tableLayoutManager.setColumnCount(4);
        listContainer.setLayoutManager(tableLayoutManager);
        listContainer.setBackground(element);
        listContainer.setItemProvider(new ComponentItemProvider(items, 4));


    }

    private void initData() {
        items = new ArrayList();
        BallFadingComponent ballFadingComponent = new BallFadingComponent(getContext());
        ballFadingComponent.setColorPaletteOn(true)
                .setEnableRotationAnimator(true)
                .setBallCount(8);

        BallBeatLoadComponent ballBeatComponent = new BallBeatLoadComponent(getContext());
        ballBeatComponent.setBallCount(3).setRadius(25).setEnableAlphaAnimator(true);

        CircularRingComponent circularRingComponent = new CircularRingComponent(this);

        ChrysantheLoadingCompoment chrysanthemumComponent = new ChrysantheLoadingCompoment(this);
        EatBeansComponent eatBeansComponent = new EatBeansComponent(this);
        RingGradientLoading ringGradientLoading = new RingGradientLoading(this);
        CubeGridComponent cubeGridComponent = new CubeGridComponent(this);

        OverWatchLoadComponent overWatchLoadComponent = new OverWatchLoadComponent(this);


        StripLoadingComponent stripLoadingComponent = new StripLoadingComponent(getContext());
        stripLoadingComponent.setRadius(0).setAutoStart(true);

        LineScaleComponent lineScaleComponent = new LineScaleComponent(this);

        TwoGearsLoadingComponent twoGearsLoadingComponent = new TwoGearsLoadingComponent(this);
        twoGearsLoadingComponent.getFirstGear().setTeethColor("#f3f707");

        FoldingCirclesComponent foldingCirclesComponent = new FoldingCirclesComponent(this);

        BallJumpLoadingComponent ballJumpLoadingComponent = new BallJumpLoadingComponent(this);
        WifiLoadingComponent wifiLoadingComponent = new WifiLoadingComponent(this);
        DoubleCircleLoadingComponent doubleCircleLoadingComponent = new DoubleCircleLoadingComponent(this);
        items.add(ballFadingComponent);
        items.add(ballBeatComponent);
        items.add(circularRingComponent);
        items.add(chrysanthemumComponent);
        items.add(eatBeansComponent);
        items.add(ringGradientLoading);
        items.add(cubeGridComponent);
        items.add(overWatchLoadComponent);
        items.add(new BallExchangeComponent(this));
        items.add(stripLoadingComponent);
        items.add(lineScaleComponent);
        items.add(twoGearsLoadingComponent);

        SearchLoadingComponent searchLoadingComponent = new SearchLoadingComponent(this);
        searchLoadingComponent.setPillarColor("#110f0f")
                .setGlassColor("#00ff4c")
                .setDuration(2000);
        items.add(searchLoadingComponent);

        items.add(foldingCirclesComponent);
        items.add(ballJumpLoadingComponent);
        items.add(wifiLoadingComponent);
        items.add(doubleCircleLoadingComponent);


        ChromeFloatingCirclesComponent chromeFloatingCirclesComponent = new ChromeFloatingCirclesComponent(this);
        items.add(chromeFloatingCirclesComponent);
        items.add(new BallDancerLoadingComponent(this));

        items.add(new WhorArcLoadingComponent(this));


        items.add(new LocatingLoadingComponent(this));
        items.add(new BallSwingLoadingComponent(this));

        SandClockComponent sandClockComponent = new SandClockComponent(this);
        items.add(sandClockComponent);
    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
